package com.hazardSoft.eStore.ejb;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import com.hazardSoft.eStore.bussines.OfficesBO;
import com.hazardSoft.eStore.common.exception.SystemException;
import com.hazardSoft.eStore.entities.Office;
import com.hazardSoft.eStore.interfaces.OfficesLocal;

/**
 * Session Bean implementation class OfficesEJB
 */
@Stateless
public class OfficesEJB implements OfficesLocal {

	public static final String EJB_NAME = OfficesEJB.class.getSimpleName()+"Local";
	
	@PersistenceContext(unitName = "EStoreJPA")
	private EntityManager entityManager;
	private OfficesBO officesBO;
	
    /**
     * Default constructor. 
     */
    public OfficesEJB() {
        officesBO = new OfficesBO();
    }

	/**
     * @throws SystemException 
	 * @see OfficesLocal#searchOfficeById(Office)
     */
    public Office searchOfficeById(Office office) throws SystemException {
        
		return officesBO.searchOfficeById(office, entityManager);
    }

	/**
     * @throws SystemException 
	 * @see OfficesLocal#listOffices()
     */
    public List<Office> listOffices() throws SystemException {
        
		return officesBO.listOffices(entityManager);
    }

	/**
     * @throws SystemException 
	 * @see OfficesLocal#updateOffice(Office)
     */
    public Office updateOffice(Office office) throws SystemException {
        
		return officesBO.updateOffice(office, entityManager);
    }

	/**
     * @throws SystemException 
	 * @see OfficesLocal#searchOfficeByName(Office)
     */
    public Office searchOfficeByName(Office office) throws SystemException {
        
		return officesBO.searchOfficeByName(office, entityManager);
    }

	/**
     * @throws SystemException 
	 * @see OfficesLocal#insertOffice(Office)
     */
    public Office insertOffice(Office office) throws SystemException {
        
		return officesBO.insertOffice(office, entityManager);
    }

	/**
     * @throws SystemException 
	 * @see OfficesLocal#removeOffice(Office)
     */
    public boolean removeOffice(Office office) throws SystemException {
        
		return officesBO.removeOffice(office, entityManager);
    }

}
